<?php
class Order extends MY_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('order_model');
        $this->load->helper('main_helper');
        $this->load->helper('text');
    }
    function index()
    {
        $numberget =15;
        $this->load->library('MY_Paginationhome');
        $this->data=null;
        if(empty($_GET['page']) and empty($_GET['keyword'])){
            $this->session->unset_userdata("keyword");
        }
        if(isset($_GET['keyword'])){
            $keyword = 	$_GET['keyword'] ;
            $this->session->set_userdata('keyword',$keyword);
            $keyword = $this->session->userdata('keyword');
        }else  $keyword ='';

        if(isset($_GET['page']))
        {
            $keyword = $this->session->userdata('keyword');
            $page = $_GET['page'];
        }else $page = 1;

        $start = ((int)$page - 1)*$numberget;
        $start = $start > 0 ? $start : 0;
        $this->data['orders']=$this->order_model->searchAjax($total,$keyword,$start,$numberget);
        //echo '<pre>'; var_dump($this->data['orders']); echo '</pre>';die;
        $config['total_rows']=$total;//tong so record
        $config['per_page']=$numberget;//xac dinh so record o moi trang
        $config['num_links']=20;
        $config['cur_page'] = $start;
        //$config['uri_segment'] = 4;//xac dinh segment chua page number
        $config['first_link'] = 'first';
        $config['last_link'] = 'last';
        $config['next_link'] = 'next';
        $config['prev_link'] = 'pres';
        $config['full_tag_open']='';//tao the div cho link phan trang
        $config['full_tag_close']='';

        $this->my_paginationhome->initialize($config);
        $this->data['paging'] = $this->my_paginationhome->create_links();

        $this->load->view('backend/order/header',$this->data);
        $this->load->view('backend/order/home',$this->data);
        $this->load->view('backend/order/footer');
    }
}
